﻿namespace CSharpPro._1013;

public class Demo
{
    public static int[] method1(int x, int y, int z)
    {
        int[] numbers = { x, y, z };
        Array.Sort(numbers);
        return numbers;
    }
    
    public static int method2()
    {
        int sum = 0;
        for (int i = 1; i <= 100; i++)
        {
            bool a = i % 7 == 0;
            bool b= (i % 10 == 7) || (i / 10 == 7);
            if (!a && !b)
            {
                Console.Write(i + " ");
                sum += i;
            }
        }
        return sum;
    }
    
    public static void method3()
    {
        for (int i = 1; i <= 9; i++)  
        {
            for (int j = 1; j <= i; j++)  
            {
                Console.Write($"{j}×{i}={i*j}\t");
            }
            Console.WriteLine();  
        }
    }
    
    public static bool IsPerfectNumber(int number)
    {
        if (number <= 1)
            return false;
        
        int sum = 1; 
        for (int i = 2; i <= number / 2; i++)
        {
            if (number % i == 0)
            {
                sum += i;
            }
        }
        return sum == number;
    }
    public static List<int> method4()
    {
        List<int> perfectNumbers = new List<int>();
        for (int i = 2; i <= 1000; i++)
        {
            if (IsPerfectNumber(i))
            {
                perfectNumbers.Add(i);
            }
        }
        return perfectNumbers;
    }
    
    public static int method5_1(int number)
    {
        if (number == 0)
            return 1;
            
        int count = 0;
        int temp = number;
        
        while (temp > 0)
        {
            temp /= 10;
            count++;
        }
        
        return count;
    }
    
    public static void method5_2(int number)
    {
        int temp = number;
        while (temp > 0)
        {
            int digit = temp % 10;
            Console.Write(digit + " ");
            temp /= 10;
        }
        Console.WriteLine();
    }
    
    public static void method6(int rows)
    {
        if (rows <= 0 || rows % 2 == 0)
        {
            Console.WriteLine("请输入正奇数作为行数！");
            return;
        }
        
        int half = rows / 2;
        
        // 打印上半部分（包括中间行）
        for (int i = 0; i <= half; i++)
        {
            // 打印空格
            for (int j = 0; j < half - i; j++)
            {
                Console.Write(" ");
            }
            
            // 打印星号
            for (int k = 0; k < 2 * i + 1; k++)
            {
                Console.Write("*");
            }
            
            Console.WriteLine();
        }
        
        // 打印下半部分
        for (int i = half - 1; i >= 0; i--)
        {
            // 打印空格
            for (int j = 0; j < half - i; j++)
            {
                Console.Write(" ");
            }
            
            // 打印星号
            for (int k = 0; k < 2 * i + 1; k++)
            {
                Console.Write("*");
            }
            
            Console.WriteLine();
        }
    }
    
    public static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        method6(a);
    }


}